#!/usr/bin/env python

import wx
import dialogs
import logging.config

from ..._app import App as BaseApp
from _meta import Meta
from _config import Config

class App(BaseApp, wx.App):
    '''App class

    @author Julot <andy.julot@gmail.com>
    @since Sunday, January 15, 2012. 05:05 PM'''

    def OnInit(self):
        setting = dialogs.Setting(withFrequency=False)
        config = Config()
        setting.device = config.Read('Device/Name', 'Dev1')
        for index in range(1, 25):
            gain = config.ReadInt('Gain/%s' % index, 5)
            setting.channels[index].gain = gain
        if setting.ShowModal() == wx.ID_OK:
            config.Write('Device/Name', setting.device)
            for index in range(1, 25):
                config.WriteInt('Gain/%s' % index, setting.channels[index].gain)
        return True
